package io.bdmc.modules.bss.controller;

import io.bdmc.common.annotation.SysLogger;
import io.bdmc.common.utils.R;
import io.bdmc.modules.bss.entity.DeviceMachineOs;
import io.bdmc.modules.bss.service.IDeviceMachineOsService;
import io.bdmc.modules.sys.controller.AbstractController;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 黄露
 * @since 2021-06-02
 */

//os控制器
@RestController
@RequestMapping("/bss/device/os")
public class DeviceMachineOsController extends AbstractController {

	@Autowired
	IDeviceMachineOsService osService;

	@GetMapping("/list")
	// "分页查询", notes = "分页查询")
	@RequiresPermissions("bss:deviceMachineOs:list")
	public R list() {
		List<DeviceMachineOs> list = osService.list();
		return R.ok().putData(list);

	}

	@SysLogger("新增")
	@PostMapping("/add")
	// "新增", notes = "新增")
	@RequiresPermissions("bss:deviceMachineOs:add")
	public R add(@RequestBody DeviceMachineOs devicemachineos) {
		Boolean b = devicemachineos.insert();
		return R.trueOrFalse(b);
	}

	@SysLogger("修改")
	@PostMapping("/update")
	// "修改", notes = "修改")
	@RequiresPermissions("bss:deviceMachineOs:update")
	public R update(@RequestBody DeviceMachineOs devicemachineos) {
		Boolean b = devicemachineos.updateById();
		return R.trueOrFalse(b);
	}

	@SysLogger("删除")
	@DeleteMapping("/delete/{machineOsId}")
	// "删除", notes = "删除")
	@RequiresPermissions("bss:deviceMachineOs:delete")
	public R delete(@PathVariable Integer machineOsId) {
		if (machineOsId > 0)
			osService.removeById(machineOsId);
		return R.ok();
	}
}
